import { request } from 'umi';
import { createCRUD } from '@/utils/api';

const route = '/user';

const crud = createCRUD<UserEntity>(route);

export { crud };

export async function getUser(id: string) {
  return await request<UserEntity>(`${route}/get_entity?id=${id}`, {
    method: 'GET',
  });
}

export async function updateRoles(data: Record<string, any>) {
  return request<Record<string, any>>(`${route}/edit_user_group`, {
    data,
    method: 'POST',
  });
}

export async function updatePassword(data: Record<string, any>) {
  return request<Record<string, any>>(`${route}/change_password`, {
    data,
    method: 'POST',
  });
}
